import * as Libs from '../../utils/Libs'
import { post } from '../../utils/fetch'
import * as commonService from '../common'
import {
  assetLiabilityMainMsg, tmodeContentMsg, assetLiabilityDetailMsg, assetLiabilityModelCompare,
  shouyeContentMsg
} from '../../utils/api'

export const getAssetLiabilityMainMsg = async (params) => {
  return post(assetLiabilityMainMsg(params), {})
}

export const getAssetLiabilityDetailMsg = async (params) => {
  return post(assetLiabilityDetailMsg(params), {})
}

export const getAssetLiabilityModelCompare = async (params) => {
  return post(assetLiabilityModelCompare(params), {})
}

export const getContentMsg = async (params) => {
  return post(tmodeContentMsg(params), {})
}

export const getShouyeContentMsg = async (params) => {
  return post(shouyeContentMsg(params), {})
}

export const geneTitle = (title, content) => {
  return {
    name: title,
    amount: Libs.numberUpperFormat(content.sumMoney || 0, false),
    yoy: (content.onRise || 0) + '%',
    qoq: (content.linkRise || 0) + '%'
  }
}
export const geneContent = (v) => {
  const linked = commonService.getLinked(v.code) || {}
  let params = Object.assign({}, v, linked)
  // const _linked = v.isDetails === 1 ? params : undefined
  const _linked = params
  return {
    name: v.codeName,
    amount: Libs.numberUpperFormat(v.sumMoney || 0, false),
    linked: _linked,
    yoy: (v.onRise || 0)+ "%",
    qoq: (v.linkRise || 0) + "%",
  }
}
